home *** CD-ROM | disk | FTP | other *** search
/ QuickTime 2.0 Beta / Quicktime 2.0 Beta.iso / Extensions / Macintosh Easy Open / Documentation / Developer / Interfaces / PInterfaces / Translation.p < prev    next >
Encoding:
Text File  |  1993-04-28  |  6.3 KB  |  186 lines  |  [TEXT/MPS ]

  1. {
  2.     File:        Translation.p
  3.  
  4.     Contains:    Pascal Interface to the Translation Manager
  5.  
  6.     Copyright:    © 1990-1993 by Apple Computer, Inc., all rights reserved.
  7. }
  8.  
  9. {$IFC UNDEFINED UsingIncludes}
  10.     {$SETC UsingIncludes := 0}
  11. {$ENDC}
  12.  
  13. {$IFC NOT UsingIncludes}
  14.     UNIT Translation;
  15.     INTERFACE
  16. {$ENDC}
  17.  
  18. {$IFC UNDEFINED UsingTranslation}
  19. {$SETC UsingTranslation := 1}
  20.  
  21. {$I+}
  22. {$SETC TranslationIncludes := UsingIncludes}
  23. {$SETC UsingIncludes := 1}
  24. {$IFC UNDEFINED UsingTypes}
  25. {$I $$Shell(PInterfaces)Types.p}
  26. {$ENDC}
  27. {$IFC UNDEFINED UsingFiles}
  28. {$I $$Shell(PInterfaces)Files.p}
  29. {$ENDC}
  30. {$IFC UNDEFINED UsingMemory}
  31. {$I $$Shell(PInterfaces)Memory.p}
  32. {$ENDC}
  33. {$IFC UNDEFINED UsingStandardFile}
  34. {$I $$Shell(PInterfaces)StandardFile.p}
  35. {$ENDC}
  36. {$IFC UNDEFINED UsingTranslationExtensions}
  37.     {$I TranslationExtensions.p}
  38. {$ENDC}
  39.  
  40. {$SETC UsingIncludes := TranslationIncludes}
  41.  
  42.  
  43. CONST
  44.     gestaltTranslationAttr = 'xlat';            { ••• move into GestaltEqu.p }
  45.     gestaltTranslationMgrExists = 0;            { ••• move into GestaltEqu.p }
  46.     gestaltTranslationMgrHintOrder = 1;            { True if hint order reversal fix in effect }
  47.     
  48.     { gestaltStandardFileAttr = 'stdf'; }        
  49.     { gestaltStandardFile58 = 0;    }
  50.     gestaltStandardFileTranslationAware = 1;    { ••• move into GestaltEqu.p }
  51.     gestaltStandardFileHasColorIcons = 2;        { ••• move into GestaltEqu.p }
  52.     
  53.     { gestaltEditionMgrAttr = 'edtn'; }    
  54.     { gestaltEditionMgrPresent    = 0; }
  55.     gestaltEditionMgrTranslationAware = 1;        { ••• move into GestaltEqu.p }
  56.     
  57.     gestaltScrapMgrAttr = 'scra';        
  58.     gestaltScrapMgrTranslationAware = 0;        { ••• move into GestaltEqu.p }
  59.     
  60.     
  61.     noTranslationPathErr = -3030;                { ••• move into Errors.p }
  62.     badTranslationSpecErr = -3031;                { ••• move into Errors.p }
  63.     noPrefAppErr = -3032;                        { ••• move into Errors.p }
  64.     
  65. {  invalidTranslationPathErr = -3025;    ••• move into Errors.p (TranslationExtensions.p }
  66. {  couldNotParseSourceFileErr = -3026;    ••• move into Errors.p (TranslationExtensions.p }
  67.     
  68.  
  69. TYPE
  70.     { block of data that describes how to translate }
  71.     FileTranslationSpec = ARRAY [1..12] OF LONGINT;
  72.     
  73.     { enumerated types on how a document can be opened }
  74.     DocOpenMethod = ( domCannot, domNative, domTranslateFirst, domWildcard );
  75.     
  76.     { Zero terminated array of file types }
  77.     TypesBlock = ARRAY [0..63] OF FileType;
  78.     TypesBlockPtr = ^TypesBlock;
  79.     
  80.     FileTypePtr =  ^FileType;
  81.     
  82.  
  83. {
  84. //////////////////////////////////////////////////////////////////////////////////////////////
  85. //
  86. //  GetFileTypesThatAppCanNativelyOpen
  87. //
  88. // This routine returns a list of all FileTypes that an application can open by itself
  89. //
  90. // Enter:    appVRefNumHint        volume where application resides (can be wrong, and if is, will be used as a starting point)
  91. //            appSignature        signature (creator) of application
  92. //            nativeTypes            pointer to a buffer to be filled with up to 64 FileTypes
  93. //
  94. // Exit:    nativeTypes            zero terminated array of FileTypes that can be opened by app
  95. //
  96. }
  97. FUNCTION GetFileTypesThatAppCanNativelyOpen(appVRefNumHint    : INTEGER;
  98.                                             appSignature    : OSType; 
  99.                                         VAR nativeTypes        : TypesBlock) :OSErr;
  100.      INLINE $701C, $ABFC;
  101.  
  102.  
  103. {
  104. //////////////////////////////////////////////////////////////////////////////////////////////
  105. //
  106. // ExtendFileTypeList
  107. //
  108. // This routine makes a new list of file types that can be translated into a type in the given list
  109. // Used by StandardFile
  110. //
  111. // Enter:    originalTypeList        pointer to list of file types that can be opened
  112. //            numberOriginalTypes        number of file types in orgTypeList
  113. //             extendedTypeList        pointer to a buffer to be filled with file types
  114. //            numberExtendedTypes        max number of file types that can be put in extendedTypeList
  115. //
  116. // Exit:    extendedTypeList        buffer filled in with file types that can be translated
  117. //            numberExtendedTypes        number of file types put in extendedTypeList
  118. //
  119. }
  120. FUNCTION ExtendFileTypeList(    originalTypeList    : FileTypePtr;
  121.                                 numberOriginalTypes    : INTEGER; 
  122.                                 extendedTypeList    : FileTypePtr;
  123.                             VAR numberExtendedTypes    : INTEGER) : OSErr;
  124.      INLINE $7009, $ABFC; 
  125.  
  126.  
  127. {
  128. ////////////////////////////////////////////////////////////////////////////////////////////////
  129. //
  130. // This routine checks if a file can be opened by a particular application.
  131. // If so, it returns if it needs to be translated first, and if so then how.
  132. // The FileTypes that the app can open are specified by nativelyOpenableTypes,
  133. // or if it is NULL, GetFileTypesThatAppCanNativelyOpen is called.
  134. //
  135. // Enter:    targetDocument        document to check if it can be opened
  136. //            appVRefNumHint        vRefNum of application to open doc ( can be wrong, and if is, will be used as a starting point)
  137. //            appSignature        signature (creator) of application to open doc
  138. //            nativeTypes            zero terminated list of FileTypes app can open natively, or NULL to use default list
  139. //            onlyNative            whether to consider if document can be translated before opening
  140. //            howToOpen            pointer to buffer in which to put how the document can be opened
  141. //            howToTranslate        pointer to buffer in which to put a FileTranslationSpec record
  142. //
  143. // Exit:    howToOpen            whether file needs to be translated to be read
  144. //            howToTranslate        if file can be translated, buffer filled in with how to translate
  145. //            returns                noErr, noPrefAppErr
  146. //
  147. }
  148. FUNCTION CanDocBeOpened(    targetDocument    : FSSpec; 
  149.                             appVRefNumHint    : INTEGER; 
  150.                             appSignature    : OSType; 
  151.                             nativeTypes        : TypesBlockPtr; 
  152.                             onlyNative         : Boolean;
  153.                         VAR howToOpen        : DocOpenMethod; 
  154.                         VAR howToTranslate    : FileTranslationSpec) : OSErr;
  155.      INLINE $701E, $ABFC; 
  156.  
  157.  
  158. {
  159. //////////////////////////////////////////////////////////////////////////////////////////////
  160. //
  161. //  TranslateFile
  162. //
  163. // This routine reads a file of one format and writes it to another file in another format. 
  164. // The information on how to translated is generated by the routine CanDocBeOpened.
  165. // TranslateFile calls through to the TranslateFile Extension's DoTranslateFile routine.  
  166. // The destination file must not exist.  It is created by this routine.  
  167. //
  168. // Enter:    sourceDocument            input file to translate
  169. //            destinationDocument        output file of translation
  170. //            howToTranslate            pointer to info on how to translate
  171. // Exit:    returns                    noErr, badTranslationSpecErr 
  172. //
  173. }
  174. FUNCTION TranslateFile(sourceDocument        : FSSpec; 
  175.                        destinationDocument    : FSSpec; 
  176.                        howToTranslate        : FileTranslationSpec) : OSErr;
  177.      INLINE $700C, $ABFC; 
  178.  
  179.  
  180.                             
  181. {$ENDC}    { UsingTranslation}
  182.  
  183. {$IFC NOT UsingIncludes}
  184.     END.
  185. {$ENDC}
  186.